public class Block {
    public static void main(String[] args) {
        Object lajiao =new Object();
        Object cu=new Object();
        Thread me=new Thread(()->{
            synchronized (lajiao) {
                System.out.println("me拿到了辣椒油");
                try {
                    Thread.sleep(30);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (cu) {
                    System.out.println("me拿到醋了");
                }
            }
        });
        Thread him=new Thread(()->{
            synchronized (cu) {
                System.out.println("him拿到醋了");
                try {
                    Thread.sleep(30);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
                synchronized (lajiao) {
                    System.out.println("him拿到辣椒油");
                }
            }
        });
        me.start();
        him.start();
    }
}
